//
//  KYZXVideoCollectionViewCell.m
//  KuYouZiXun
//
//  Created by lanou on 15/8/10.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "KYZXVideoCollectionViewCell.h"

#import "UIImageView+WebCache.h"

#import "KYZXUserInfo.h"
@implementation KYZXVideoCollectionViewCell

- (void)awakeFromNib {

    [super awakeFromNib];
    self.contentView.backgroundColor = [[KYZXUserInfo standardKYZXUserInfo] backgroundColor];
    self.titleLabel.textColor = [KYZXUserInfo standardKYZXUserInfo].textColor;
    self.isImagePlay = [KYZXUserInfo standardKYZXUserInfo].isImagePlay;
}


- (void)setModel:(KYZXVideoListModel *)model{

    _model = model;
    
    if (self.isImagePlay) {
        [self.thumbImageView sd_setImageWithURL:[NSURL URLWithString:model.thumbnailUrl] placeholderImage:[UIImage imageNamed:@"_backimage"]];
    }
    else{
        [self.thumbImageView setImage:[UIImage imageNamed:@"_backimage"]];
    }
    self.titleLabel.text = model.title;
    if([model.hits floatValue] >= 10000.0)
    {
        self.hitsLabel.text = [NSString stringWithFormat:@"%.1fw",[model.hits floatValue] / 10000.0];
    }
    else
    self.hitsLabel.text = [model.hits stringValue];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    
    self.contentView.backgroundColor = [[KYZXUserInfo standardKYZXUserInfo] backgroundColor];
    self.titleLabel.textColor = [KYZXUserInfo standardKYZXUserInfo].textColor;
    if ([keyPath isEqualToString:@"isImagePlay"]) {
        self.isImagePlay = [KYZXUserInfo standardKYZXUserInfo].isImagePlay;
     
    }
}
@end
